<template>
  <div class="wrapper">
    <!--    检验申请项目清单-->
    <div class="labList">
      <div class="title">检验申请项目清单</div>
      <el-scrollbar ref="elbar" style="width:100%;height:200px">
        <div class="tablist">
          <Bluetable
            ref="blueTable"
            :t-head="PatientExamListHead"
            :t-data="PatientExamList"
            @operateClick="operateClickPatientExamList"
          />
          <pagination
            :total="GetPatientExamListPage.total"
            :page.sync="GetPatientExamListPage.pagenum"
            :limit.sync="GetPatientExamListPage.pagesize"
            @pagination="pagePatientExamList"
          />
        </div>
      </el-scrollbar>
    </div>
    <!--    检验结果-->
    <div class="labDetail">
      <div class="title">检验结果明细</div>
      <el-scrollbar ref="elbar" style="width:100%;height:200px">
        <div class="tablist">
          <Bluetable
            ref="blueTable"
            :t-data="PatientExamDetailList"
            :t-head="PatientExamDetailListHead"
          />
          <pagination
            :total="PatientExamDetailListPage.total"
            :page.sync="PatientExamDetailListPage.pagenum"
            :limit.sync="PatientExamDetailListPage.pagesize"
            @pagination="pagePatientExamDetailListPage"
          />
        </div>
      </el-scrollbar>
    </div>
  </div>
</template>

<script>
import { GetPatientExamList, GetPatientExamDetailList } from '@/api/cpw'
export default {
  name: 'PatientExamList',
  props: {
    patientDetailFather: {
      type: Object
    }
  },
  data() {
    return {
      patientDetail: {},
      GetPatientExamListPage: {
        pagesize: 10,
        pagenum: 1,
        total: 0
      },
      PatientExamList: [],
      PatientExamListHead: [
        {
          operate: ['查看'],
          label: '操作',
          link: true,
          width: '100px'
        }, {
          prop: 'requestno',
          label: '项目编码'
        }, {
          prop: 'examname',
          label: '项目名称'
        }, {
          prop: 'bodypart',
          label: '部位'
        }, {
          prop: 'doctorname',
          label: '申请医生'
        }, {
          prop: 'reporttime',
          label: '检查时间'
        }
      ],
      Requestno: '',
      PatientExamDetailList: [],
      PatientExamDetailListHead: [
        {
          prop: 'examresult',
          label: '结果'
        }
      ],
      PatientExamDetailListPage: {
        pagesize: 10,
        pagenum: 1,
        total: 0
      }
    }
  },
  watch: {
    patientDetailFather(val, oldVal) {
      this.patientDetail = val
      this.getPatientExamList()
    }
  },
  methods: {
    getPatientExamList() {
      this.GetPatientExamListPage = {
        pagesize: 10,
        pagenum: 1,
        total: 0
      }
      this.GetPatientExamList()
    },
    async GetPatientExamList() {
      await GetPatientExamList({
        pagesize: this.GetPatientExamListPage.pagesize,
        pagenum: this.GetPatientExamListPage.pagenum,
        json: {
          Patient_id: this.patientDetail.patient_id,
          Visit_id: this.patientDetail.visit_id
        }
      }).then(res => {
        this.PatientExamList = res.PatientExamList
        this.GetPatientExamListPage.total = res.records
      }).catch(err => {
        console.log(err)
      })
    },
    operateClickPatientExamList(val, row) {
      this.Requestno = row.requestno
      this.getPatientExamDetailList()
    },
    pagePatientExamList(type) {
      this.GetPatientExamListPage.pagenum = type.page
      this.GetPatientExamListPage.pagesize = type.limit
      this.GetPatientExamList()
    },

    getPatientExamDetailList() {
      this.PatientExamDetailListPage = {
        pagesize: 10,
        pagenum: 1,
        total: 0
      }
      this.GetPatientExamDetailList()
    },
    async GetPatientExamDetailList() {
      await GetPatientExamDetailList({
        pagesize: this.PatientExamDetailListPage.pagesize,
        pagenum: this.PatientExamDetailListPage.pagenum,
        json: {
          Patient_id: this.patientDetail.patient_id,
          Visit_id: this.patientDetail.visit_id,
          Requestno: this.Requestno
        }
      }).then(res => {
        this.PatientExamDetailList = res.PatientExamDetailList
        this.PatientExamDetailListPage.total = res.PatientExamDetailList.length
      }).catch(err => {
        console.log(err)
      })
    },
    pagePatientExamDetailListPage(type) {
      this.PatientExamDetailListPage.pagenum = type.page
      this.PatientExamDetailListPage.pagesize = type.limit
      this.GetPatientExamDetailList()
    }
  }
}
</script>

<style scoped lang="scss">
  .wrapper{
    /*color: #29a4f2;*/
    padding: 20px;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    .labList{
      margin-top: 10px;
    }
    .labDetail{
      margin-top: 10px;
    }
    .title{
      border-left: #2f90fd 2px solid;
      padding-left: 20px;
    }
    .tablist{
      margin-top: 20px;
    }

  }

</style>
